package com.example.studentdemo.constant;

import lombok.Getter;

@Getter
public enum RoleConstant {
    ADMIN("ADMIN"),
    TEACHER("TEACHER"),
    STUDENT("STUDENT");

    private final String role;

    RoleConstant(String role) {
        this.role = role;
    }

    public final static String ADMIN_ROLE = "ADMIN";
    public final static String TEACHER_ROLE = "TEACHER";
    public final static String STUDENT_ROLE = "STUDENT";

    /**
     * 根据字符串获取对应的枚举
     */
    public static RoleConstant getByRole(String role) {
        if (role == null) return null;
        for (RoleConstant r : values()) {
            if (r.role.equalsIgnoreCase(role)) {
                return r;
            }
        }
        return null;
    }
}